@extends('wap.layout')
@section('content')
	<!--文本区域-->
	<div class="weui-cells__title">新建文件夹</div>
	<div class="weui-cells">
	  <div class="weui-cell">
	    <div class="weui-cell__bd">
	      <input class="weui-input" type="text" placeholder="请输入文件夹名称" id="folder_name">
	    </div>
	  </div>
	</div>
	<!--文本区域end-->
	<!--按钮区域-->
	<div class="uploadBtnList btn">
		<a href="javascript:;" class="weui-btn weui-btn_primary" id="submit">确定</a>
	</div>
	<!--按钮区域end-->
	@stop

	@section('ownJs')
<script>
	var parent_id = getParameterByName('folder_id');
	var is_public = parseInt(getParameterByName('is_public'));
$(function() {
	$('#submit').click(function(){
		create_folder();
	})
});

	function create_folder(){
		var name = $('#folder_name').val();
		$.ajax({
			type:'get',
			url:' /user_file/create',
			data:{name:name, parent_id:parent_id,is_public:is_public},
			dataType:'json',
			success:function(result){console.log(result);
				if(result.code == 0){
					$.toast("新建成功");
					setTimeout(function() {
						location.href = '/list?folder_id='+parent_id+'&is_public='+is_public;
					}, 1000)

				}else if(result.code == -1){
					location.href = '/error';
				}else{
					$.showLoading("创建失败");
					setTimeout(function() {
						$.hideLoading();
					}, 3000)
				}
			}
		});
	}
</script>
@stop
